﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Diagnostics;

namespace Wicresoft.Platform.Workflows.Mobile.Tasks
{
    public sealed class Purchase : IResumeTask
    {
        public ProcessState State
        {
            get { return ProcessState.Purchase; }
        }

        public Wicresoft_Platform_Processes_Mobile Resume(ActivityContext context, Bookmark bookmark, Wicresoft_Platform_Processes_Mobile wppMobile)
        {
            Debug.Assert(wppMobile != null, "wppMobile cannot be null");

            using (MobileEntities db = new MobileEntities(true))
            {
                var e = db.Wicresoft_Platform_Processes_Mobile.Single(p => p.Id == wppMobile.Id);

                e.PurchaseTime = wppMobile.PurchaseTime;
                e.PurchaseBy = wppMobile.PurchaseBy;
                e.PurchaseComment = wppMobile.PurchaseComment;

                e.AssignedTo = wppMobile.AssignedTo;
                e.CurrentState = wppMobile.CurrentState;
                e.LastModifiedTime = wppMobile.LastModifiedTime;
                e.LastModifiedBy = wppMobile.LastModifiedBy;

                db.SaveChanges();
                return e;
            }
        }
    }
}
